Skip to content

Conversation

@josh-wong
Copy link
Member

Description

This PR adds a function to generate a log file that contains broken links when building the docs site. This log file is for reference when building the docs site locally. Therefore, we should regularly check for broken links.

Important

Once all links in versions of docs that are under Maintenance Support have been fixed, we should consider changing warn to throw so that we can catch broken links immediately, rather than needing to check on a regular basis.

Specifications:

  • Setting onBrokenLinks to warn catches external links, Markdown links, and anchor links, according to Docusaurus' documentation.
  • Only versions of docs that are under Maintenance Support are added to the output log file.
    • Versions are based on the versions listed in src/pages/unsupported-versions.mdx.
  • The output log file is ignored when generated.
    • Its contents should be generated and addressed locally, so there's no reason to include it in the build files.

Related issues and/or PRs

N/A

Changes made

  • Changed the onBrokenMarkdownLinks and on AnchorLinks options to ignore since onBrokenLinks is set to warn and catches those two types of broken links as well as external links.
  • Created a script that lists broken links and their originating pages (versions of docs under Maintenance Support only) into a .log file.
  • Added the broken-link log generator to the build command in package.json.
  • Updated the .gitignore to exclude the output .log file that contains broken links.

Checklist

The following is a best-effort checklist. If any items in this checklist are not applicable to this PR or are dependent on other, unmerged PRs, please still mark the checkboxes after you have read and understood each item.

  • I have updated the side navigation as necessary.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes.
  • Any remaining open issues linked to this PR are documented and up-to-date (Jira, GitHub, etc.).
  • My changes generate no new warnings.
  • Any dependent changes in other PRs have been merged and published.

Additional notes (optional)

N/A

A list of all broken links for versions of docs still under Maintenance Support are generated in **brokenLinks.log**. To eliminate potentially redundant entries in the log, only `onBrokenLinks` is set to `warn`.
**brokenLinks.log** is for internal/local purposes, so we don't need to include it in the build files.
To reduce work in fixing broken links for versions that we no longer support, the script checks for broken link for versions of docs that are currently under Maintenance Support.
@josh-wong josh-wong added the enhancement New feature or request label Mar 25, 2025
@josh-wong josh-wong self-assigned this Mar 25, 2025
@josh-wong josh-wong merged commit 104accb into main Mar 25, 2025
1 check passed
@josh-wong josh-wong deleted the docusaurus/add-broken-link-log-generator branch March 25, 2025 10:17
josh-wong added a commit that referenced this pull request May 14, 2025
* Create filter-broken-link-warnings.js

* Make all broken links show warning

A list of all broken links for versions of docs still under Maintenance Support are generated in **brokenLinks.log**. To eliminate potentially redundant entries in the log, only `onBrokenLinks` is set to `warn`.

* Add `brokenLinks.log`

**brokenLinks.log** is for internal/local purposes, so we don't need to include it in the build files.

* Add broken-link log generator to `build` command

* Show broken links for versions under Maintenance Support

To reduce work in fixing broken links for versions that we no longer support, the script checks for broken link for versions of docs that are currently under Maintenance Support.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant